<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>index</title>
    <script src="/auth/jquery.js"></script>
    <script>
        $(function () {
            var storage = window.localStorage;
            var token = storage.getItem("token");
            console.log(token);

            $.ajax({
                type:"get",
                headers:{"token":token},
                url:"/com-springcloud-coursedata/course/courses/",
                dataType:"json",
                success:function (result) {
                    if(result.statusCode === 401){
                        alert("请先登录");
                        location.href = "/auth/login.html"
                    }else{
                        console.log(result);
                    }
                }
            });

            $("#delToken").click(function () {
                storage.removeItem("token");
                console.log("删除成功");
            });
        });
    </script>

</head>
<body>
   <p>index</p>
   <input id="delToken" type="button" value="删除token" />
</body>
</html>